package com.swhysc.information.service.impl;


import com.swhysc.information.entity.InformationDataDirectoryEx;
import com.swhysc.information.vo.InformationDataColumnExcelExVo;
import com.swhysc.information.vo.InformationDataTableExcelExVo;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;

/**
 * @创建人 liangzai
 * @创建时间 2022/11/11
 * @描述
 */
@Data
@Slf4j
public class ExportThreadCallableEx implements Callable<List> {

    private InformationDataDirectoryEx dirRepositoryOne;
    private Set<String> dirIds;
    private InformationDataTableExServiceImpl informationDataTableService;
    private List lists = new ArrayList();

    public ExportThreadCallableEx(InformationDataDirectoryEx dirRepositoryOne, Set<String> dirIds, InformationDataTableExServiceImpl informationDataTableService) {
        this.dirRepositoryOne = dirRepositoryOne;
        this.dirIds = dirIds;
        this.informationDataTableService = informationDataTableService;
    }

    @Override
    public List<List<Object>> call() throws Exception {
        long getDataStartTime = System.currentTimeMillis();
        List<InformationDataTableExcelExVo> directoryList = informationDataTableService.getInformationDataTableExcelVos(dirRepositoryOne, dirIds);
        long getDataendTime = System.currentTimeMillis();
        log.info("【获取表数据需要的时间 ={}秒】" ,(getDataendTime -getDataStartTime)/1000);
        informationDataTableService.builderLevelName(directoryList);
        lists.add(directoryList);
        long getStartTime = System.currentTimeMillis();
        List<InformationDataColumnExcelExVo> excelDataColumnExcelDtoList = informationDataTableService.getExcelDataColumnExcelDtoList(directoryList);
        long getendTime = System.currentTimeMillis();
        log.info("【获取字段数据需要的时间 ={}秒】" ,(getendTime -getStartTime)/1000);
        lists.add(excelDataColumnExcelDtoList);
        return lists;
    }
}
